﻿
namespace ApplicationGenerator.DataAccess
{
    public class FormDataBaseCommands : IDataBaseCommands
    {

        #region SQL Commands

        private const string CreateFormsTableSchema = "CREATE TABLE AG_FORMS(" +
                                                        "[AG_ID] [uniqueidentifier] NOT NULL," +
                                                        "[AG_NAME] [nvarchar](50) NOT NULL UNIQUE NONCLUSTERED," +
                                                        "[AG_BINARY_DATA] [varbinary](max) NOT NULL" +
                                                        ")";
        private const string InsertToAgFormsTable = "INSERT INTO AG_FORMS  VALUES(@id,@name,@binData)";
        private const string SelectFormFromAgFormsTable = "SELECT AG_BINARY_DATA FROM AG_FORMS WHERE AG_ID = @id;";
        private const string SelectFormFromAgFormsTableByName = "SELECT AG_BINARY_DATA FROM AG_FORMS " +
                                                                "WHERE AG_NAME = @name;";
        private const string UpdateFormFromAgFormsTable = "UPDATE AG_FORMS SET AG_BINARY_DATA = @bin_data WHERE AG_NAME = @name;";
        private const string SelectFormNames = "SELECT AG_NAME FROM AG_FORMS;";
        private const string SelectVersionInfoFromAgFormsTable = "SELECT AG_ID,AG_NAME FROM AG_FORMS";

        #endregion

        #region Methods

        public string CreateTableCommand()
        {
            return CreateFormsTableSchema;
        }

        public string InsertToTableCommand()
        {
            return InsertToAgFormsTable;
        }

        public string UpdateToTableCommand()
        {
            return UpdateFormFromAgFormsTable;
        }

        public string SelectFromTableCommand()
        {
            return SelectFormFromAgFormsTable;
        }

        public string SelectFromTableByNameCommand()
        {
            return SelectFormFromAgFormsTableByName;
        }

        public string SelectNames()
        {
            return SelectFormNames;
        }

        public string SelectVersionInfo()
        {
            return SelectVersionInfoFromAgFormsTable;
        }

        public string SelectName()
        {
            return "" ;
        }

        #endregion
    }
}
